using System;
using System.Collections;
using System.Collections.Generic;

namespace Elvex
{
    public class Dictionary<TKey1, TKey2, TValue>
    {
        class DictionaryKey : IEquatable<DictionaryKey>
        {
            public TKey1 Key1 { get; }

            public TKey2 Key2 { get; }

            public DictionaryKey(TKey1 key1, TKey2 key2)
            {
                Key1 = key1;
                Key2 = key2;
            }

            public override bool Equals(object obj)
            {
                return Equals(obj as DictionaryKey);
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return (Key1.GetHashCode() /* * 1369 */) ^
                    Key2.GetHashCode();
                }
            }

            public bool Equals(DictionaryKey other)
            {
                return other != null &&
                    other.Key1.Equals(Key1) &&
                    other.Key2.Equals(Key2);
            }
        }

        Dictionary<DictionaryKey, TValue> m_dict = new Dictionary<DictionaryKey, TValue>();

        public void Add(TKey1 key1, TKey2 key2, TValue value)
        {
            m_dict.Add(new DictionaryKey(key1, key2), value);
        }

        public bool TryGetValue(TKey1 key1, TKey2 key2, out TValue value)
        {
            return m_dict.TryGetValue(new DictionaryKey(key1, key2), out value);
        }
    }
}

